package edu.polsl.bio.str.manager.dao;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import java.util.List;

/**
 * //todo class description
 * <p/>
 * Created on: Jun 21, 2011 12:37:11 PM <br/>
 * <a href="http://www.polsl.pl">www.polsl.pl</a>
 *
 * @author lukasz.olczak@polsl.pl
 */
public abstract class BaseDao extends HibernateDaoSupport {
  /**
   * slf4j Logger.
   */
  private static final Logger log = LoggerFactory.getLogger(BaseDao.class.getName());

  protected <T> T getUniqueResult(List results) {
    if (results == null || results.size() == 0) {
      return null;
    }

    if (results.size() > 1) {
      throw new RuntimeException("Results list contains more than 1 element");
    }

    return (T) results.get(0);
  }
}
